﻿using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using psieve.sieve;

namespace psieveTest
{
    [TestClass]
    public class TestSieveSpeed
    {
        //private const int Elements = 100000;
        //private const long ExpectedCount = 9592;

        //private const int Elements = 200000;
        //private const long ExpectedCount = 17984;

        //private const int Elements = 1000000;
        //private const long ExpectedCount = 78498;

        //private const int Elements = 50000000;
        //private const long ExpectedCount = 3001134;

        private const int Elements = 100000000;
        private const long ExpectedCount = 5761455;

        [TestMethod]
        public void TestSpeedSundaram()
        {
            long count = new Sundaram().Sieve(Elements).LongCount();
            Assert.AreEqual(ExpectedCount, count);
        }

        [TestMethod]
        public void TestSpeedEratosthenes()
        {
            long count = new Eratosthenes().Sieve(Elements).LongCount();
            Assert.AreEqual(ExpectedCount, count);
        }

        [TestMethod]
        public void TestSpeedEratosthenes2()
        {
            long count = new Eratosthenes2().Sieve(Elements).LongCount();
            Assert.AreEqual(ExpectedCount, count);
        }

        [TestMethod]
        public void TestSpeedEratosthenes_F()
        {
            //long count = Sieve.findPrimes(Elements).LongCount();
            long count = Sieve.countPrimes(Sieve.findPrimes(Elements));
            Assert.AreEqual(ExpectedCount, count);
        }
    }
}
